import ajaxAsync from 'vue-xiaobu-utils'

/**
 * 获取订单气泡
 */
function getOrderBubble() {
  return ajaxAsync('/user/order/bubble', {}).then(res => {
    let orderTypeList = []
    res.LIST.forEach(item => {
      orderTypeList.push({
        orderKey: item.KEY,
        orderBubble: item.BUBBLE
      })
    })
    return orderTypeList
    // return res
  })
}

/**
 * 获取邀请有礼广告位
 * @param {string} enName
 */
function getAdInvite(enName) {
  let postData = {
    EN_NAME: enName
  }

  return ajaxAsync('/ad/list', postData).then(res => {
    return res.COUNT
  })
}

/**
 * 获取优惠券数量
 */
function getCouponsCount() {
  return ajaxAsync('/user/ticket/statistic', {}).then(res => {
    return res.TICKET_NUMS['type_coupon']
  })
}
export { getOrderBubble, getAdInvite, getCouponsCount }
